package com.cncf.controller.manage;

import com.cncf.entity.InvalidReportView;
import com.cncf.response.ResponseData;
import com.cncf.service.InvalidReportViewService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author zj
 */
@Api(value = "manage", description = "管理端作废报告原件的相关接口")
@Controller
@RequestMapping("/manage/invalidReportView")
public class ManageInvalidReportViewController {
    private static final Logger logger = LoggerFactory.getLogger(ManageInvalidReportViewController.class);

    @Autowired
    private InvalidReportViewService invalidReportViewService;

    @ApiOperation(value = "获取所有的作废报告原件", notes = "不提供page和pageSize就不分页")
    @RequestMapping(value = "getAllInvalidReportView", method = {RequestMethod.GET})
    @ResponseBody
    public ResponseData<List<InvalidReportView>> getAllInvalidReportView(
            @ApiParam("page") @RequestParam(value = "page", required = false) Integer page,
            @ApiParam("pageSize") @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        ResponseData<List<InvalidReportView>> responseData = new ResponseData<>();
        List<InvalidReportView> list = invalidReportViewService.getAllInvalidReportView(page, pageSize);
        responseData.jsonFill(1, null, list);
        responseData.setCount(invalidReportViewService.sum());
        return responseData;
    }

}
